home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / PASCTXT.ZIP / INTRO.TXT < prev    next >
Text File  |  1988-01-15  |  11KB  |  257 lines

  1.  
  2.                 Introduction to the TURBO Pascal Tutorial
  3.  
  4.  
  5.              Assuming  you know nothing at all about Pascal, and  in
  6.         fact,  that  you  may  know  nothing  about  programming  in
  7.         general, we will begin to study Pascal.  If you are  already
  8.         somewhat  familiar with programming and  especially  Pascal,
  9.         you  will  probably want to skip very  quickly  through  the
  10.         first few chapters.  You should at least skim the first  few
  11.         chapters,  and  you  should  read  the  remainder  of   this
  12.         introduction.
  13.  
  14.              A  few comments are in order to get us started  in  the
  15.         right direction.  The sample programs included on the  disks
  16.         are  designed to teach you the basics of Pascal and they  do
  17.         not  include any clever or tricky code.  Nearly all  of  the
  18.         programs  are  really  quite dumb as  far  as  being  useful
  19.         programs,  but  all  will teach one or  more  principles  of
  20.         Pascal.   I have seen one tutorial that included a  12  page
  21.         program  as  the first example.  In fact there were  only  2
  22.         example  programs  in  the  entire  tutorial,  and  it   was
  23.         impossible to glean the essentials of programming from  that
  24.         system.  For this reason, I will completely bypass any  long
  25.         programs  until the very end of this tutorial. In  order  to
  26.         illustrate fundamental concepts used in Pascal  programming,
  27.         all  programs will be very short and concise until we  reach
  28.         the last chapter.
  29.  
  30.              The  last  chapter has some rather  large  programs  to
  31.         illustrate to you how to write a large program.  It would be
  32.         a  disservice  to you to show you all of the  constructs  of
  33.         Pascal  and  not  show you how to put  them  together  in  a
  34.         meaningful  way to build a large program.  After  completing
  35.         all of the fundamentals of Pascal, it will then be very easy
  36.         for you to use the tools learned to build as large a program
  37.         as you desire.
  38.  
  39.              Another  problem I have noticed in example programs  is
  40.         the  use  of one word for all definitions.  For  example,  a
  41.         sort program is stored in a file called SORT, the program is
  42.         named Sort, and various parts of the program are referred to
  43.         as Sort1, Sort2, etc.  This can be confusing since you  have
  44.         no  idea  if  the  program name must  be  the  same  as  the
  45.         filename, or if any of the other names were chosen to be the
  46.         same  because of some obscure rule not  clearly  documented.
  47.         For  this  reason,  the  example  programs  use   completely
  48.         arbitrary  names whenever the choice of a name adds  nothing
  49.         to  the  readability  or  clarity  of  a  program.   As   an
  50.         illustration of this, the first program is named  Puppy_Dog.
  51.         This  adds nothing to the understanding of the  program  but
  52.         does  illustrate that the program name means nothing to  the
  53.         Pascal compiler concerning what the program does.
  54.  
  55.  
  56.  
  57.  
  58.                                   Page 1
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.                 Introduction to the TURBO Pascal Tutorial
  69.  
  70.  
  71.              Due  to the fundamental design of the Pascal  language,
  72.         certain words are "reserved" and can only be used for  their
  73.         defined  purposes.   These are listed in your  TURBO  Pascal
  74.         reference manual (page 37 - version 3.0; page 196 -  version
  75.         4.0).   All  of  the sample programs in  this  tutorial  are
  76.         written  with the reserved words in all lower-case  letters,
  77.         and  the user variables in lower case with the first  letter
  78.         capitalized  since  this is becoming the  accepted  industry
  79.         standard.   Don't worry about what reserved words  are  yet,
  80.         they will be completely defined later.
  81.  
  82.                             WHAT IS A COMPILER?
  83.  
  84.              There  are  two  primary methods used  in  running  any
  85.         computer  program  that  is written in a  readable  form  of
  86.         English.    The   first  method  is  an   interpreter.    An
  87.         interpreter  is  a program that looks at each  line  of  the
  88.         "English"  program, decides what the "English" on that  line
  89.         means, and does what it says to do.  If one of the lines  is
  90.         executed  repeatedly, it must be scanned and  analyzed  each
  91.         time,  greatly slowing down the solution of the  problem  at
  92.         hand.   A  compiler, on the other hand, is  a  program  that
  93.         looks at each statement one time and converts it into a code
  94.         that  the computer understands directly.  When the  compiled
  95.         program  is  actually  run, the computer does  not  have  to
  96.         figure  out  what each statement means, it is already  in  a
  97.         form that the computer can run directly, hence a much faster
  98.         execution of the program.
  99.  
  100.              This   tutorial  is  written  especially  for   Borland
  101.         International's  TURBO  Pascal  compilers  version  3.0   or
  102.         version 4.0.  These are very high quality compilers that can
  103.         do nearly anything you will ask them to do since they are so
  104.         flexible.  The original intent of this tutorial was to write
  105.         it  in  such a way that it would be completely  generic  and
  106.         usable  with any good Pascal compiler.  The  programmers  at
  107.         Borland  included  a  great many nonstandard  aids  for  the
  108.         Pascal language and resulted in a very good product that has
  109.         dominated the market for microcomputers.  To completely omit
  110.         all of the extensions would do those of you with the Borland
  111.         compiler  a real disservice, and to include  the  extensions
  112.         would not allow other compilers to be used effectively  with
  113.         this tutorial.
  114.  
  115.              The  decision  was  made  to  stay  with  the   Borland
  116.         extensions and make the tutorial very difficult to use  with
  117.         other  compilers.   TURBO Pascal is so inexpensive  that  it
  118.         would  be a wise decision to purchase a copy solely for  the
  119.         purpose  of  learning the Pascal programming  language  then
  120.         moving to a larger compiler on a minicomputer or a mainframe
  121.         using  the accumulated knowledge to very quickly  learn  the
  122.  
  123.  
  124.                                   Page 2
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.                 Introduction to the TURBO Pascal Tutorial
  135.  
  136.  
  137.         extensions  provided  by that particular compiler.   At  any
  138.         rate,  this tutorial will not teach you everything you  will
  139.         ever need to know about Pascal.  It will, however, teach you
  140.         the  fundamentals and the terminology needed to progress  on
  141.         your own into more advanced topics of Pascal and programming
  142.         in general.  You will find that experience will be your best
  143.         teacher.
  144.  
  145.              Some of the example files will only work properly  with
  146.         TURBO  Pascal version 3.0 and some will only  work  properly
  147.         with  version 4.0, but most will work with either.  It  will
  148.         be clearly indicated to you which files will work with  each
  149.         of the two versions of TURBO Pascal.
  150.  
  151.                     WHAT ABOUT TURBO PASCAL VERSION 2.0?
  152.  
  153.              Most  of  the files will compile  properly  with  TURBO
  154.         Pascal version 2.0, but no warning will be given since  that
  155.         version has been superseded for so long.  It will pay you to
  156.         purchase a newer version because of the flexibility.  If you
  157.         choose not to however, this tutorial will work fine in  most
  158.         cases  if  you  follow the  instructions  for  TURBO  Pascal
  159.         version 3.0.
  160.  
  161.                    PREPARATION FOR USE OF THIS TUTORIAL.
  162.  
  163.              Copy the example files onto your TURBO working disk and
  164.         you  are  ready to begin, provided of course that  you  have
  165.         already  learned  how to start the TURBO system and  how  to
  166.         edit  a Pascal file.  Be sure you make a backup copy of  the
  167.         Pascal  tutorial disks so you cannot accidentally  lose  all
  168.         information  on  the distribution disks.  If you  are  using
  169.         TURBO  Pascal version 3.0, you should read Chapter 1 of  the
  170.         reference  manual to be ready to use this tutorial,  and  if
  171.         you  are  using TURBO Pascal version 4.0,  you  should  read
  172.         parts of chapters 1, 2, & 11 of your reference manual.   You
  173.         should  be  familiar with use of the  editor  supplied  with
  174.         TURBO Pascal before beginning.
  175.  
  176.              If  you are not using TURBO Pascal, you will  still  be
  177.         able  to  compile and execute many of  these  Pascal  files,
  178.         since  most  of  the examples use  standard  Pascal  syntax.
  179.         There will be some statements used which are unique to TURBO
  180.         Pascal and will probably not work with your compiler.   This
  181.         will  be  especially true when you come to  the  chapter  on
  182.         standard input and output since this is where most compilers
  183.         differ.   Unfortunately, this is one of the  most  important
  184.         aspects of any programming language, since it is required to
  185.         get data into and out of the computer to do anything useful.
  186.  
  187.  
  188.  
  189.  
  190.                                   Page 3
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.                 Introduction to the TURBO Pascal Tutorial
  201.  
  202.  
  203.              It  is  highly suggested that you  do  the  programming
  204.         exercises  after  you complete the study for  each  chapter.
  205.         They  are carefully selected to test your  understanding  of
  206.         the material covered in that chapter.  If you do not  write,
  207.         enter,  debug,  and  run these programs, you  will  only  be
  208.         proficient  at  reading  Pascal.  If you  do  the  exercises
  209.         completely,  you  will have a good start at being  a  Pascal
  210.         program writer.
  211.  
  212.              It should also be mentioned that this tutorial will not
  213.         teach  you  everything  you will ever  need  to  know  about
  214.         Pascal.   You will continue to learn new techniques as  long
  215.         as  you continue to write programs.  Experience is the  best
  216.         teacher  here just as it is in any endeavor.  This  tutorial
  217.         will teach you enough about Pascal that you should feel very
  218.         comfortable  as you search through the reference manual  for
  219.         some  topic.  You will also be able to read  and  understand
  220.         any Pascal program you find in textbooks or magazines.
  221.  
  222.              When you are ready, I will meet you in Chapter 1.
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.                                   Page 4
  257.